home *** CD-ROM | disk | FTP | other *** search
/ Sprite 1984 - 1993 / Sprite 1984 - 1993.iso / src / X11R4 / cmds / X / ddx / cfb / cfbgc.c < prev    next >
Encoding:
C/C++ Source or Header  |  1991-02-28  |  18.8 KB  |  803 lines

  1. /***********************************************************
  2. Copyright 1987 by Digital Equipment Corporation, Maynard, Massachusetts,
  3. and the Massachusetts Institute of Technology, Cambridge, Massachusetts.
  4.  
  5.                         All Rights Reserved
  6.  
  7. Permission to use, copy, modify, and distribute this software and its 
  8. documentation for any purpose and without fee is hereby granted, 
  9. provided that the above copyright notice appear in all copies and that
  10. both that copyright notice and this permission notice appear in 
  11. supporting documentation, and that the names of Digital or MIT not be
  12. used in advertising or publicity pertaining to distribution of the
  13. software without specific, written prior permission.  
  14.  
  15. DIGITAL DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, INCLUDING
  16. ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO EVENT SHALL
  17. DIGITAL BE LIABLE FOR ANY SPECIAL, INDIRECT OR CONSEQUENTIAL DAMAGES OR
  18. ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS,
  19. WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION,
  20. ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
  21. SOFTWARE.
  22.  
  23. ******************************************************************/
  24.  
  25. /* $XConsortium: cfbgc.c,v 5.32.1.1 90/03/21 10:16:47 rws Exp $ */
  26.  
  27. #include "X.h"
  28. #include "Xmd.h"
  29. #include "Xproto.h"
  30. #include "dixfontstr.h"
  31. #include "fontstruct.h"
  32. #include "gcstruct.h"
  33. #include "windowstr.h"
  34. #include "pixmapstr.h"
  35. #include "scrnintstr.h"
  36. #include "region.h"
  37.  
  38. #include "cfb.h"
  39. #include "mistruct.h"
  40. #include "mibstore.h"
  41.  
  42. #include "cfbmskbits.h"
  43. #include "cfb8bit.h"
  44.  
  45. static void cfbValidateGC(), cfbChangeGC(), cfbCopyGC(), cfbDestroyGC();
  46. static void cfbChangeClip(), cfbDestroyClip(), cfbCopyClip();
  47. static cfbDestroyOps();
  48.  
  49. static GCFuncs cfbFuncs = {
  50.     cfbValidateGC,
  51.     cfbChangeGC,
  52.     cfbCopyGC,
  53.     cfbDestroyGC,
  54.     cfbChangeClip,
  55.     cfbDestroyClip,
  56.     cfbCopyClip,
  57. };
  58.  
  59. static GCOps    cfbTEOps = {
  60.     cfbSolidFS,
  61.     cfbSetSpans,
  62.     cfbPutImage,
  63.     cfbCopyArea,
  64.     cfbCopyPlane,
  65.     cfbPolyPoint,
  66.     cfbLineSS,
  67.     cfbSegmentSS,
  68.     miPolyRectangle,
  69. #if PPW == 4
  70.     cfbZeroPolyArcSS8Copy,
  71. #else
  72.     miZeroPolyArc,
  73. #endif
  74.     miFillPolygon,
  75.     cfbPolyFillRect,
  76.     cfbPolyFillArcSolidCopy,
  77.     miPolyText8,
  78.     miPolyText16,
  79.     miImageText8,
  80.     miImageText16,
  81. #if PPW == 4
  82.     cfbTEGlyphBlt8,
  83.     cfbPolyGlyphBlt8,
  84.     cfbPushPixels8,
  85. #else
  86.     cfbTEGlyphBlt,
  87.     miPolyGlyphBlt,
  88.     mfbPushPixels,
  89. #endif
  90.     NULL,
  91. };
  92.  
  93. static GCOps    cfbNonTEOps = {
  94.     cfbSolidFS,
  95.     cfbSetSpans,
  96.     cfbPutImage,
  97.     cfbCopyArea,
  98.     cfbCopyPlane,
  99.     cfbPolyPoint,
  100.     cfbLineSS,
  101.     cfbSegmentSS,
  102.     miPolyRectangle,
  103. #if PPW == 4
  104.     cfbZeroPolyArcSS8Copy,
  105. #else
  106.     miZeroPolyArc,
  107. #endif
  108.     miFillPolygon,
  109.     cfbPolyFillRect,
  110.     cfbPolyFillArcSolidCopy,
  111.     miPolyText8,
  112.     miPolyText16,
  113.     miImageText8,
  114.     miImageText16,
  115.     miImageGlyphBlt,
  116. #if PPW == 4
  117.     cfbPolyGlyphBlt8,
  118.     cfbPushPixels8,
  119. #else
  120.     miPolyGlyphBlt,
  121.     mfbPushPixels,
  122. #endif
  123.     NULL,
  124. };
  125.  
  126. static GCOps *
  127. matchCommon (pGC)
  128.     GCPtr   pGC;
  129. {
  130.     if (pGC->lineWidth != 0)
  131.     return 0;
  132.     if (pGC->lineStyle != LineSolid)
  133.     return 0;
  134.     if (pGC->fillStyle != FillSolid)
  135.     return 0;
  136.     if ((pGC->alu != GXcopy) || ((pGC->planemask & PMSK) != PMSK))
  137.     return 0;
  138.     if (pGC->font &&
  139.     (pGC->font->pFI->maxbounds.metrics.rightSideBearing -
  140.          pGC->font->pFI->minbounds.metrics.leftSideBearing) <= 32)
  141.     {
  142.     if (pGC->font->pFI->terminalFont
  143. #if PPW == 4
  144.         && pGC->font->pFI->maxbounds.metrics.characterWidth >= 4
  145. #endif
  146.     )
  147.         return &cfbTEOps;
  148.     else
  149.         return &cfbNonTEOps;
  150.     }
  151.     return 0;
  152. }
  153.  
  154. Bool
  155. cfbCreateGC(pGC)
  156.     register GCPtr pGC;
  157. {
  158.     cfbPrivGC  *pPriv;
  159.  
  160.     switch (pGC->depth) {
  161.     case 1:
  162.     return (mfbCreateGC(pGC));
  163.     case PSZ:
  164.     break;
  165.     default:
  166.     ErrorF("cfbCreateGC: unsupported depth: %d\n", pGC->depth);
  167.     return FALSE;
  168.     }
  169.     pGC->clientClip = NULL;
  170.     pGC->clientClipType = CT_NONE;
  171.  
  172.     /*
  173.      * some of the output primitives aren't really necessary, since they
  174.      * will be filled in ValidateGC because of dix/CreateGC() setting all
  175.      * the change bits.  Others are necessary because although they depend
  176.      * on being a color frame buffer, they don't change 
  177.      */
  178.  
  179.     pGC->ops = &cfbNonTEOps;
  180.     pGC->funcs = &cfbFuncs;
  181.  
  182.     /* cfb wants to translate before scan conversion */
  183.     pGC->miTranslate = 1;
  184.  
  185.     pPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
  186.     pPriv->rop = pGC->alu;
  187.     pPriv->fExpose = TRUE;
  188.     pPriv->freeCompClip = FALSE;
  189.     pPriv->pRotatedPixmap = (PixmapPtr) NULL;
  190.     return TRUE;
  191. }
  192.  
  193. /*ARGSUSED*/
  194. static void
  195. cfbChangeGC(pGC, mask)
  196.     GC            *pGC;
  197.     BITS32        mask;
  198. {
  199.     return;
  200. }
  201.  
  202. static void
  203. cfbDestroyGC(pGC)
  204.     GC             *pGC;
  205. {
  206.     cfbPrivGC *pPriv;
  207.  
  208.     pPriv = (cfbPrivGC *)(pGC->devPrivates[cfbGCPrivateIndex].ptr);
  209.     if (pPriv->freeCompClip)
  210.     (*pGC->pScreen->RegionDestroy)(pPriv->pCompositeClip);
  211.     cfbDestroyOps (pGC->ops);
  212. }
  213.  
  214. /*
  215.  * create a private op array for a gc
  216.  */
  217.  
  218. static GCOps *
  219. cfbCreateOps (prototype)
  220.     GCOps    *prototype;
  221. {
  222.     GCOps    *ret;
  223.     extern Bool    Must_have_memory;
  224.  
  225.     /* XXX */ Must_have_memory = TRUE;
  226.     ret = (GCOps *) xalloc (sizeof(GCOps));
  227.     /* XXX */ Must_have_memory = FALSE;
  228.     if (!ret)
  229.     return 0;
  230.     *ret = *prototype;
  231.     ret->devPrivate.val = 1;
  232.     return ret;
  233. }
  234.  
  235. static
  236. cfbDestroyOps (ops)
  237.     GCOps   *ops;
  238. {
  239.     if (ops->devPrivate.val)
  240.     xfree (ops);
  241. }
  242.  
  243. /* Clipping conventions
  244.     if the drawable is a window
  245.         CT_REGION ==> pCompositeClip really is the composite
  246.         CT_other ==> pCompositeClip is the window clip region
  247.     if the drawable is a pixmap
  248.         CT_REGION ==> pCompositeClip is the translated client region
  249.         clipped to the pixmap boundary
  250.         CT_other ==> pCompositeClip is the pixmap bounding box
  251. */
  252.  
  253. static void
  254. cfbValidateGC(pGC, changes, pDrawable)
  255.     register GCPtr  pGC;
  256.     Mask        changes;
  257.     DrawablePtr        pDrawable;
  258. {
  259.     WindowPtr   pWin;
  260.     int         mask;        /* stateChanges */
  261.     int         index;        /* used for stepping through bitfields */
  262.     int         new_line, new_text, new_fillspans, new_fillrct;
  263.     int        new_rotate;
  264.     int        xrot, yrot;
  265.     /* flags for changing the proc vector */
  266.     cfbPrivGCPtr devPriv;
  267.  
  268.     new_rotate = pGC->lastWinOrg.x != pDrawable->x ||
  269.          pGC->lastWinOrg.y != pDrawable->y;
  270.  
  271.     pGC->lastWinOrg.x = pDrawable->x;
  272.     pGC->lastWinOrg.y = pDrawable->y;
  273.     if (pDrawable->type == DRAWABLE_WINDOW)
  274.     {
  275.     pWin = (WindowPtr) pDrawable;
  276.     }
  277.     else
  278.     {
  279.     pWin = (WindowPtr) NULL;
  280.     }
  281.  
  282.     devPriv = ((cfbPrivGCPtr) (pGC->devPrivates[cfbGCPrivateIndex].ptr));
  283.  
  284.     /*
  285.      * if the client clip is different or moved OR the subwindowMode has
  286.      * changed OR the window's clip has changed since the last validation
  287.      * we need to recompute the composite clip 
  288.      */
  289.  
  290.     if ((changes & (GCClipXOrigin|GCClipYOrigin|GCClipMask|GCSubwindowMode)) ||
  291.     (pDrawable->serialNumber != (pGC->serialNumber & DRAWABLE_SERIAL_BITS))
  292.     )
  293.     {
  294.     ScreenPtr pScreen = pGC->pScreen;
  295.  
  296.     if (pWin) {
  297.         RegionPtr   pregWin;
  298.         Bool        freeTmpClip, freeCompClip;
  299.  
  300.         if (pGC->subWindowMode == IncludeInferiors) {
  301.         pregWin = NotClippedByChildren(pWin);
  302.         freeTmpClip = TRUE;
  303.         }
  304.         else {
  305.         pregWin = &pWin->clipList;
  306.         freeTmpClip = FALSE;
  307.         }
  308.         freeCompClip = devPriv->freeCompClip;
  309.  
  310.         /*
  311.          * if there is no client clip, we can get by with just keeping
  312.          * the pointer we got, and remembering whether or not should
  313.          * destroy (or maybe re-use) it later.  this way, we avoid
  314.          * unnecessary copying of regions.  (this wins especially if
  315.          * many clients clip by children and have no client clip.) 
  316.          */
  317.         if (pGC->clientClipType == CT_NONE) {
  318.         if (freeCompClip)
  319.             (*pScreen->RegionDestroy) (devPriv->pCompositeClip);
  320.         devPriv->pCompositeClip = pregWin;
  321.         devPriv->freeCompClip = freeTmpClip;
  322.         }
  323.         else {
  324.         /*
  325.          * we need one 'real' region to put into the composite
  326.          * clip. if pregWin the current composite clip are real,
  327.          * we can get rid of one. if pregWin is real and the
  328.          * current composite clip isn't, use pregWin for the
  329.          * composite clip. if the current composite clip is real
  330.          * and pregWin isn't, use the current composite clip. if
  331.          * neither is real, create a new region. 
  332.          */
  333.  
  334.         (*pScreen->TranslateRegion)(pGC->clientClip,
  335.                         pDrawable->x + pGC->clipOrg.x,
  336.                         pDrawable->y + pGC->clipOrg.y);
  337.                           
  338.         if (freeCompClip)
  339.         {
  340.             (*pGC->pScreen->Intersect)(devPriv->pCompositeClip,
  341.                            pregWin, pGC->clientClip);
  342.             if (freeTmpClip)
  343.             (*pScreen->RegionDestroy)(pregWin);
  344.         }
  345.         else if (freeTmpClip)
  346.         {
  347.             (*pScreen->Intersect)(pregWin, pregWin, pGC->clientClip);
  348.             devPriv->pCompositeClip = pregWin;
  349.         }
  350.         else
  351.         {
  352.             devPriv->pCompositeClip = (*pScreen->RegionCreate)(NullBox,
  353.                                        0);
  354.             (*pScreen->Intersect)(devPriv->pCompositeClip,
  355.                       pregWin, pGC->clientClip);
  356.         }
  357.         devPriv->freeCompClip = TRUE;
  358.         (*pScreen->TranslateRegion)(pGC->clientClip,
  359.                         -(pDrawable->x + pGC->clipOrg.x),
  360.                         -(pDrawable->y + pGC->clipOrg.y));
  361.                           
  362.         }
  363.     }            /* end of composite clip for a window */
  364.     else {
  365.         BoxRec      pixbounds;
  366.  
  367.         /* XXX should we translate by drawable.x/y here ? */
  368.         pixbounds.x1 = 0;
  369.         pixbounds.y1 = 0;
  370.         pixbounds.x2 = pDrawable->width;
  371.         pixbounds.y2 = pDrawable->height;
  372.  
  373.         if (devPriv->freeCompClip)
  374.         (*pScreen->RegionReset)(devPriv->pCompositeClip, &pixbounds);
  375.         else {
  376.         devPriv->freeCompClip = TRUE;
  377.         devPriv->pCompositeClip = (*pScreen->RegionCreate)(&pixbounds,
  378.                                    1);
  379.         }
  380.  
  381.         if (pGC->clientClipType == CT_REGION)
  382.         {
  383.         (*pScreen->TranslateRegion)(devPriv->pCompositeClip,
  384.                         -pGC->clipOrg.x, -pGC->clipOrg.y);
  385.         (*pScreen->Intersect)(devPriv->pCompositeClip,
  386.                       devPriv->pCompositeClip,
  387.                       pGC->clientClip);
  388.         (*pScreen->TranslateRegion)(devPriv->pCompositeClip,
  389.                         pGC->clipOrg.x, pGC->clipOrg.y);
  390.         }
  391.     }            /* end of composute clip for pixmap */
  392.     }
  393.  
  394.     new_line = FALSE;
  395.     new_text = FALSE;
  396.     new_fillspans = FALSE;
  397.     new_fillrct = FALSE;
  398.  
  399.     mask = changes;
  400.     while (mask) {
  401.     index = lowbit (mask);
  402.     mask &= ~index;
  403.  
  404.     /*
  405.      * this switch acculmulates a list of which procedures might have
  406.      * to change due to changes in the GC.  in some cases (e.g.
  407.      * changing one 16 bit tile for another) we might not really need
  408.      * a change, but the code is being paranoid. this sort of batching
  409.      * wins if, for example, the alu and the font have been changed,
  410.      * or any other pair of items that both change the same thing. 
  411.      */
  412.     switch (index) {
  413.     case GCFunction:
  414.         new_fillrct = TRUE;
  415.         if (!pGC->lineWidth)
  416.         new_line = TRUE;
  417.     case GCForeground:
  418.         new_text = TRUE;
  419.         break;
  420.     case GCPlaneMask:
  421.         new_text = TRUE;
  422.         new_fillrct = TRUE;
  423.         if (!pGC->lineWidth)
  424.         new_line = TRUE;
  425.         break;
  426.     case GCBackground:
  427.         new_fillspans = TRUE;
  428.         break;
  429.     case GCLineStyle:
  430.     case GCLineWidth:
  431.     case GCJoinStyle:
  432.         new_line = TRUE;
  433.         break;
  434.     case GCCapStyle:
  435.         break;
  436.     case GCFillStyle:
  437.         new_text = TRUE;
  438.         new_fillspans = TRUE;
  439.         new_line = TRUE;
  440.         new_fillrct = TRUE;
  441.         break;
  442.     case GCFillRule:
  443.         break;
  444.     case GCTile:
  445.         new_fillspans = TRUE;
  446.         new_fillrct = TRUE;
  447.         break;
  448.  
  449.     case GCStipple:
  450.         if (pGC->stipple)
  451.         {
  452.         int width = pGC->stipple->drawable.width;
  453.         PixmapPtr nstipple;
  454.  
  455.         if ((width <= 32) && !(width & (width - 1)) &&
  456.             (nstipple = cfbCopyPixmap(pGC->stipple)))
  457.         {
  458.             cfbPadPixmap(nstipple);
  459.             cfbDestroyPixmap(pGC->stipple);
  460.             pGC->stipple = nstipple;
  461.         }
  462.         }
  463.         new_fillspans = TRUE;
  464.         new_fillrct = TRUE;
  465.         break;
  466.  
  467.     case GCTileStipXOrigin:
  468.         new_rotate = TRUE;
  469.         break;
  470.  
  471.     case GCTileStipYOrigin:
  472.         new_rotate = TRUE;
  473.         break;
  474.  
  475.     case GCFont:
  476.         new_text = TRUE;
  477.         break;
  478.     case GCSubwindowMode:
  479.         break;
  480.     case GCGraphicsExposures:
  481.         break;
  482.     case GCClipXOrigin:
  483.         break;
  484.     case GCClipYOrigin:
  485.         break;
  486.     case GCClipMask:
  487.         break;
  488.     case GCDashOffset:
  489.         break;
  490.     case GCDashList:
  491.         break;
  492.     case GCArcMode:
  493.         break;
  494.     default:
  495.         break;
  496.     }
  497.     }
  498.  
  499.     /*
  500.      * If the drawable has changed,  check its depth & ensure suitable
  501.      * entries are in the proc vector. 
  502.      */
  503.     if (pDrawable->serialNumber != (pGC->serialNumber & (DRAWABLE_SERIAL_BITS))) {
  504.     new_fillspans = TRUE;    /* deal with FillSpans later */
  505.     }
  506.  
  507.     if (new_rotate || new_fillspans)
  508.     {
  509.     Bool new_pix = FALSE;
  510.  
  511.     xrot = pGC->patOrg.x + pDrawable->x;
  512.     yrot = pGC->patOrg.y + pDrawable->y;
  513.  
  514.     switch (pGC->fillStyle)
  515.     {
  516.     case FillTiled:
  517.         if (!pGC->tileIsPixel)
  518.         {
  519.         int width = pGC->tile.pixmap->drawable.width * PSZ;
  520.  
  521.         if ((width <= 32) && !(width & (width - 1)))
  522.         {
  523.             cfbCopyRotatePixmap(pGC->tile.pixmap,
  524.                     &devPriv->pRotatedPixmap,
  525.                     xrot, yrot);
  526.             new_pix = TRUE;
  527.         }
  528.         }
  529.         break;
  530. #if (PPW == 4)
  531.     case FillStippled:
  532.     case FillOpaqueStippled:
  533.         {
  534.         int width = pGC->stipple->drawable.width;
  535.  
  536.         if ((width <= 32) && !(width & (width - 1)))
  537.         {
  538.             mfbCopyRotatePixmap(pGC->stipple,
  539.                     &devPriv->pRotatedPixmap, xrot, yrot);
  540.             new_pix = TRUE;
  541.         }
  542.         }
  543.         break;
  544. #endif
  545.     }
  546.     if (!new_pix && devPriv->pRotatedPixmap)
  547.     {
  548.         cfbDestroyPixmap(devPriv->pRotatedPixmap);
  549.         devPriv->pRotatedPixmap = (PixmapPtr) NULL;
  550.     }
  551.     }
  552.  
  553.     if (new_line || new_fillspans || new_text || new_fillrct)
  554.     {
  555.     GCOps    *newops;
  556.  
  557.     if (newops = matchCommon (pGC))
  558.      {
  559.         if (pGC->ops->devPrivate.val)
  560.         cfbDestroyOps (pGC->ops);
  561.         pGC->ops = newops;
  562.         new_line = new_fillspans = new_text = new_fillrct = 0;
  563.     }
  564.      else
  565.      {
  566.         if (!pGC->ops->devPrivate.val)
  567.         {
  568.         pGC->ops = cfbCreateOps (pGC->ops);
  569.         pGC->ops->devPrivate.val = 1;
  570.         }
  571.     }
  572.     }
  573.  
  574.     /* deal with the changes we've collected */
  575.  
  576.     if (new_line)
  577.     {
  578.     pGC->ops->PolySegment = miPolySegment;
  579.     if (pGC->lineWidth == 0)
  580.     {
  581. #if PPW == 4
  582.         if ((pGC->lineStyle == LineSolid) && (pGC->fillStyle == FillSolid)
  583.         && (pGC->alu == GXcopy) && ((pGC->planemask & PMSK) == PMSK))
  584.         pGC->ops->PolyArc = cfbZeroPolyArcSS8Copy;
  585.         else
  586. #endif
  587.         pGC->ops->PolyArc = miZeroPolyArc;
  588.     }
  589.     else
  590.         pGC->ops->PolyArc = miPolyArc;
  591.     switch (pGC->lineStyle)
  592.     {
  593.     case LineSolid:
  594.         if(pGC->lineWidth == 0)
  595.         {
  596.         if (pGC->fillStyle == FillSolid)
  597.         {
  598.             pGC->ops->Polylines = cfbLineSS;
  599.             pGC->ops->PolySegment = cfbSegmentSS;
  600.         }
  601.          else
  602.             pGC->ops->Polylines = miZeroLine;
  603.         }
  604.         else
  605.         pGC->ops->Polylines = miWideLine;
  606.         break;
  607.     case LineOnOffDash:
  608.     case LineDoubleDash:
  609.         if (pGC->lineWidth == 0 && pGC->fillStyle == FillSolid)
  610.         {
  611.         pGC->ops->Polylines = cfbLineSD;
  612.         pGC->ops->PolySegment = cfbSegmentSD;
  613.         } else
  614.         pGC->ops->Polylines = miWideDash;
  615.         break;
  616.     }
  617.     }
  618.  
  619.     if (new_text && (pGC->font))
  620.     {
  621.         if ((pGC->font->pFI->maxbounds.metrics.rightSideBearing -
  622.              pGC->font->pFI->minbounds.metrics.leftSideBearing) > 32)
  623.         {
  624.             pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
  625.             pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
  626.         }
  627.         else
  628.         {
  629. #if PPW == 4
  630.         if (pGC->alu == GXcopy &&
  631.         (pGC->planemask & PMSK) == PMSK &&
  632.         pGC->fillStyle == FillSolid)
  633.         {
  634.         pGC->ops->PolyGlyphBlt = cfbPolyGlyphBlt8;
  635.         }
  636.         else
  637. #endif
  638.         pGC->ops->PolyGlyphBlt = miPolyGlyphBlt;
  639.             /* special case ImageGlyphBlt for terminal emulator fonts */
  640.             if (pGC->font->pFI->terminalFont
  641. #if PPW == 4
  642.         && pGC->font->pFI->maxbounds.metrics.characterWidth >= 4
  643. #endif
  644.         )
  645.         {
  646. #if PPW == 4
  647.                 pGC->ops->ImageGlyphBlt = cfbTEGlyphBlt8;
  648. #else
  649.                 pGC->ops->ImageGlyphBlt = cfbTEGlyphBlt;
  650. #endif
  651.         }
  652.             else
  653.                 pGC->ops->ImageGlyphBlt = miImageGlyphBlt;
  654.         }
  655.     }    
  656.  
  657.  
  658.     if (new_fillspans) {
  659.     switch (pGC->fillStyle) {
  660.     case FillSolid:
  661.         pGC->ops->FillSpans = cfbSolidFS;
  662.         break;
  663.     case FillTiled:
  664.         pGC->ops->FillSpans = cfbUnnaturalTileFS;
  665.         break;
  666.     case FillStippled:
  667.         pGC->ops->FillSpans = cfbUnnaturalStippleFS;
  668.         break;
  669.     case FillOpaqueStippled:
  670.         if (pGC->fgPixel == pGC->bgPixel)
  671.         pGC->ops->FillSpans = cfbSolidFS;
  672.         else
  673.         pGC->ops->FillSpans = cfbUnnaturalStippleFS;
  674.         break;
  675.     default:
  676.         FatalError("cfbValidateGC: illegal fillStyle\n");
  677.     }
  678.     } /* end of new_fillspans */
  679.  
  680.     if (new_fillrct) {
  681.     pGC->ops->PolyFillRect = miPolyFillRect;
  682.     pGC->ops->PolyFillArc = miPolyFillArc;
  683.     pGC->ops->PushPixels = mfbPushPixels;
  684.     switch (pGC->fillStyle)
  685.     {
  686.     case FillSolid:
  687.         if (((pGC->alu == GXcopy || pGC->alu == GXxor) &&
  688.         ((pGC->planemask & PMSK) == PMSK)) ||
  689.         pGC->alu == GXinvert)
  690.         {
  691.         pGC->ops->PolyFillRect = cfbPolyFillRect;
  692.         }
  693.         if (pGC->alu == GXcopy &&
  694.         ((pGC->planemask & PMSK) == PMSK))
  695.         {
  696.         pGC->ops->PushPixels = cfbPushPixels8;
  697.         pGC->ops->PolyFillArc = cfbPolyFillArcSolidCopy;
  698.         }
  699.         break;
  700.     case FillTiled:
  701.         if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK)
  702.         {
  703.         pGC->ops->PolyFillRect = cfbPolyFillRect;
  704.         }
  705.         break;
  706. #if (PPW == 4)
  707.     case FillStippled:
  708.     case FillOpaqueStippled:
  709.         if (pGC->alu == GXcopy && (pGC->planemask & PMSK) == PMSK &&
  710.             devPriv->pRotatedPixmap)
  711.         {
  712.         pGC->ops->PolyFillRect = cfbPolyFillRect;
  713.         }
  714.         break;
  715. #endif
  716.     }
  717.     }
  718. }
  719.  
  720. static void
  721. cfbDestroyClip(pGC)
  722.     GCPtr    pGC;
  723. {
  724.     if(pGC->clientClipType == CT_NONE)
  725.     return;
  726.     else if (pGC->clientClipType == CT_PIXMAP)
  727.     {
  728.     cfbDestroyPixmap((PixmapPtr)(pGC->clientClip));
  729.     }
  730.     else
  731.     {
  732.     /* we know we'll never have a list of rectangles, since
  733.        ChangeClip immediately turns them into a region 
  734.     */
  735.         (*pGC->pScreen->RegionDestroy)(pGC->clientClip);
  736.     }
  737.     pGC->clientClip = NULL;
  738.     pGC->clientClipType = CT_NONE;
  739. }
  740.  
  741. static void
  742. cfbChangeClip(pGC, type, pvalue, nrects)
  743.     GCPtr    pGC;
  744.     int        type;
  745.     pointer    pvalue;
  746.     int        nrects;
  747. {
  748.     cfbDestroyClip(pGC);
  749.     if(type == CT_PIXMAP)
  750.     {
  751.     pGC->clientClip = (pointer) (*pGC->pScreen->BitmapToRegion)((PixmapPtr)pvalue);
  752.     (*pGC->pScreen->DestroyPixmap)(pvalue);
  753.     }
  754.     else if (type == CT_REGION) {
  755.     /* stuff the region in the GC */
  756.     pGC->clientClip = pvalue;
  757.     }
  758.     else if (type != CT_NONE)
  759.     {
  760.     pGC->clientClip = (pointer) (*pGC->pScreen->RectsToRegion)(nrects,
  761.                             (xRectangle *)pvalue,
  762.                             type);
  763.     xfree(pvalue);
  764.     }
  765.     pGC->clientClipType = (type != CT_NONE && pGC->clientClip) ? CT_REGION :
  766.                                  CT_NONE;
  767.     pGC->stateChanges |= GCClipMask;
  768. }
  769.  
  770. static void
  771. cfbCopyClip (pgcDst, pgcSrc)
  772.     GCPtr pgcDst, pgcSrc;
  773. {
  774.     RegionPtr prgnNew;
  775.  
  776.     switch(pgcSrc->clientClipType)
  777.     {
  778.       case CT_PIXMAP:
  779.     ((PixmapPtr) pgcSrc->clientClip)->refcnt++;
  780.     /* Fall through !! */
  781.       case CT_NONE:
  782.         cfbChangeClip(pgcDst, (int)pgcSrc->clientClipType, pgcSrc->clientClip,
  783.               0);
  784.         break;
  785.       case CT_REGION:
  786.         prgnNew = (*pgcSrc->pScreen->RegionCreate)(NULL, 1);
  787.         (*pgcSrc->pScreen->RegionCopy)(prgnNew,
  788.                                        (RegionPtr)(pgcSrc->clientClip));
  789.         cfbChangeClip(pgcDst, CT_REGION, (pointer)prgnNew, 0);
  790.         break;
  791.     }
  792. }
  793.  
  794. /*ARGSUSED*/
  795. static void
  796. cfbCopyGC (pGCSrc, changes, pGCDst)
  797.     GCPtr    pGCSrc;
  798.     Mask     changes;
  799.     GCPtr    pGCDst;
  800. {
  801.     return;
  802. }
  803.